package com.lxl.workbench.service.impl;

import com.lxl.commons.mapper.IMapper;
import com.lxl.commons.mapper.impl.LibraryMapperImpl;
import com.lxl.settings.entity.User;
import com.lxl.workbench.dao.LibraryDao;
import com.lxl.workbench.dao.LibraryDaoImpl;
import com.lxl.workbench.entity.Curator;
import com.lxl.workbench.entity.Library;
import com.lxl.workbench.service.LibraryService;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 北上寻海
 */
public class LibraryServiceImpl implements LibraryService {
    LibraryDao libraryDao = new LibraryDaoImpl();
    IMapper libraryMapper =new LibraryMapperImpl();

    @Override
    public void insertLibraryByCondition(User user, Curator curator, Library library) throws SQLException {
        libraryDao.insertLibrary(user,curator,library);
    }

    @Override
    public void updateLibraryByCondition(Library library,Curator curator,User user) throws SQLException {
        libraryDao.updateLibrary(library,curator,user);
    }

    @Override
    public int deleteLibraryByIds(String[] delIds) throws SQLException {
        return libraryDao.deleteLibraryByIds(delIds);
    }

    @Override
    public List<Library> queryLibraryByCondition(String libraryName, String libraryLocation) throws SQLException {
        return libraryMapper.mapper(libraryDao.selectLibraryCondition(libraryName,libraryLocation)) ;
    }

    @Override
    public List<Library> queryLibraryById(String id) throws SQLException {
        return libraryMapper.mapper(libraryDao.selectLibraryById(id));
    }

    @Override
    public List<Library> selectLibraryByIds(String[] ids) throws SQLException {
        return libraryMapper.mapper(libraryDao.selectLibraryByIds(ids));
    }


    @Override
    public void deleteLibraryConditionByIds(String[] libraryIds, String[] curatorIds, String[] userIds) throws SQLException {
        libraryDao.deleteLibraryConditionByIds(libraryIds,curatorIds,userIds);
    }
}
